package active;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.ArrayList;

/**
 * @author 陈华旺
 * @version 1.0
 * @date 2023年11月21日 16:55
 * @Description TODO
 */
@WebServlet("/test11/view")
public class Test11View extends HttpServlet {

    @Override
    protected void service(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        System.out.println("/test11/view - Test11View - service");

        ArrayList<Double> list = (ArrayList<Double>) req.getAttribute("list");

        //        基于数据显示页面
        StringBuffer temp = new StringBuffer();
        temp.append("<!DOCTYPE HTML>");
        temp.append("<html lang=\"zh-cn\">");
        temp.append("<head>");
        temp.append("<meta charset=\"UTF-8\">");
        temp.append("<meta name=\"viewport\"");
        temp.append("content=\"width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0\">");
        temp.append("<meta http-equiv=\"X-UA-Compatible\" content=\"ie=edge\">");
        temp.append("<title>标准结构1111</title>");
        temp.append("</head>");
        temp.append("<body>");
        temp.append("<ul>");
        for (int i = 0; i < list.size(); i++) {
            temp.append("<li>").append( list.get(i) ).append("</li>");
        }
        temp.append("</ul>");
        temp.append("</body>");
        temp.append("</html>");

        resp.setContentType("text/html;charset=utf-8");
        resp.getWriter().println(temp);
    }
}

